package com.ruoyi.project.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.LiveRoomResult;
import com.ruoyi.project.system.service.ILiveRoomResultService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 对局结果Controller
 * 
 * @author david
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/data/liveRoomResult")
public class LiveRoomResultController extends BaseController
{
    @Autowired
    private ILiveRoomResultService liveRoomResultService;

    /**
     * 查询对局结果列表
     */
    @PreAuthorize("@ss.hasPermi('data:liveRoomResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveRoomResult liveRoomResult)
    {
        startPage();
        List<LiveRoomResult> list = liveRoomResultService.selectLiveRoomResultList(liveRoomResult);
        return getDataTable(list);
    }

    /**
     * 导出对局结果列表
     */
    @PreAuthorize("@ss.hasPermi('data:liveRoomResult:export')")
    @Log(title = "对局结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LiveRoomResult liveRoomResult)
    {
        List<LiveRoomResult> list = liveRoomResultService.selectLiveRoomResultList(liveRoomResult);
        ExcelUtil<LiveRoomResult> util = new ExcelUtil<LiveRoomResult>(LiveRoomResult.class);
        util.exportExcel(response, list, "对局结果数据");
    }

    /**
     * 获取对局结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('data:liveRoomResult:query')")
    @GetMapping(value = "/{liveRoomId}")
    public AjaxResult getInfo(@PathVariable("liveRoomId") String liveRoomId)
    {
        return success(liveRoomResultService.selectLiveRoomResultByLiveRoomId(liveRoomId));
    }

    /**
     * 新增对局结果
     */
    @PreAuthorize("@ss.hasPermi('data:liveRoomResult:add')")
    @Log(title = "对局结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveRoomResult liveRoomResult)
    {
        return toAjax(liveRoomResultService.insertLiveRoomResult(liveRoomResult));
    }

    /**
     * 修改对局结果
     */
    @PreAuthorize("@ss.hasPermi('data:liveRoomResult:edit')")
    @Log(title = "对局结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveRoomResult liveRoomResult)
    {
        return toAjax(liveRoomResultService.updateLiveRoomResult(liveRoomResult));
    }

    /**
     * 删除对局结果
     */
    @PreAuthorize("@ss.hasPermi('data:liveRoomResult:remove')")
    @Log(title = "对局结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{liveRoomIds}")
    public AjaxResult remove(@PathVariable String[] liveRoomIds)
    {
        return toAjax(liveRoomResultService.deleteLiveRoomResultByLiveRoomIds(liveRoomIds));
    }
}
